﻿//-----------------------------------------------------------------------
// <summary>
//  The file contains a class that used to treat style cop settings 
// </summary>
// <copyright file="ShellView.xaml.cs" company="DSSoftLogic">
//     Copyright@ DSSoftLogic 2011, Non-Commercial. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Property.ShellApplication
{
    using System;
    using System.ComponentModel.Composition;
    using System.Diagnostics.CodeAnalysis;
    using System.Net;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Microsoft.Practices.Prism.Modularity;
    using Property.Silverlight.Module;
    using Property.Silverlight.ViewModelEx;
    using Telerik.Windows.Controls;

    /// <summary>
    /// <see cref="UserControl"/> class providing the main UI for the application.
    /// </summary>
    [Export]
    public partial class ShellView : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellView"/> class.
        /// </summary>
        public ShellView()
        {
            InitializeComponent();
            //Type MD = typeof(PropertyModule);
            //string moduleName = MD.Name;
            //string assembly = MD.Assembly.ToString();
            //string type = MD.BaseType.TypeHandle.ToString();
            //// moduleManager.ModuleDownloadProgressChanged += moduleManager_ModuleDownloadProgressChanged;
        }

        ////void moduleManager_ModuleDownloadProgressChanged(object sender, ModuleDownloadProgressChangedEventArgs e)
        ////{
        ////    // we only collect download information for Module1Impl module.
        ////    if (e.ModuleInfo.ModuleName != "PropertyModule")
        ////        return;
        ////}

        /// <summary>
        /// Sets the view model.
        /// </summary>
        ////[Import]
        ////[SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly", Justification = "Needs to be a property to be composed by MEF")]
        ////public ShellViewModel ViewModel
        ////{
        ////    set
        ////    {
        ////        this.DataContext = value;
        ////    }
        ////}

        /// <summary>
        /// After the Frame navigates, ensure the <see cref="HyperlinkButton"/> representing the current page is selected
        /// </summary>
        private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
        {
            //foreach (UIElement child in LinksStackPanel.Children)
            //{
            //    HyperlinkButton hb = child as HyperlinkButton;
            //    if (hb != null && hb.NavigateUri != null)
            //    {
            //        if (hb.NavigateUri.ToString().Equals(e.Uri.ToString()))
            //        {
            //            VisualStateManager.GoToState(hb, "ActiveLink", true);
            //        }
            //        else
            //        {
            //            VisualStateManager.GoToState(hb, "InactiveLink", true);
            //        }
            //    }
            //}
        }

        /// <summary>
        /// If an error occurs during navigation, show an error window
        /// </summary>
        private void ContentFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            e.Handled = true;
            //ErrorWindow.CreateNew(e.Exception);
        }

        /// <summary>
        /// The rad menu item_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void RadMenuItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadMenuItem item = e.Source as RadMenuItem;

            if (item != null)
            {
                switch (item.Header.ToString())
                {
                    case "NewProject":
                        ////this.ContentFrame.Navigate(new Uri("/About", UriKind.Relative));
                        break;
                }
            }


        }
    }
}
